package org.easybuy.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.easybuy.entity.User;
import org.easybuy.service.UserService;
import org.easybuy.serviceimpol.UserServiceImpol;
/**
 * @author许高峰
 * @注册servlet
 * 
 * */
public class RegisterUser extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=utf-8");
		String user = request.getParameter("l_user");
		String pwd = request.getParameter("l_pwd2");
		String email = request.getParameter("l_email");
		String tel = request.getParameter("l_tel");
		String sex = request.getParameter("l_sex");
		int sex1 = Integer.parseInt(sex);
		UserService userService = new UserServiceImpol();
		User user2 = new User();
		user2.setLoginName(user);
		user2.setPassword(pwd);
		user2.setSex(sex1);
		user2.setEmail(email);
		user2.setMoblie(tel);
		userService.insertUser(user2);
		request.getRequestDispatcher("../Login.jsp").forward(request, response);
	}

}
